<DataTable Data="data" TItem="Person" IsNarrow IsHoverable
           IsBordered IsStriped IsFullwidth>
    <DataTableColumn Sortable Label="Id" Prop="Id"/>
    <DataTableColumn Sortable SortFunc="sortFun" Label="名称" Prop="Name"/>
    <DataTableColumn Sortable Label="年龄" Prop="Age"/>
    <DataTableColumn Label="性别" Prop="Gender"/>
    <DataTableColumn Label="生日" Format="yyyy-MM-dd HH:mm" Prop="Birthday"/>
</DataTable>
<Pagination TotalCount="@totalCount" PageIndex="pageIndex" PageSize="pageSize" OnPageChange="onPage"
            NextText="下一页" PrevText="上一页" IsCentered IsSmall/>

@code{
    int pageIndex = 1;
    int pageSize = 5;
    int totalCount = 0;
    IEnumerable<Person> data;
    //分页
    void onPage(int page)
    {
        pageIndex = page;
        searchData();
    }

    //查询后台数据
    void searchData()
    {
        data = Person.GetPageData("", pageIndex, pageSize, out int total);
        totalCount = total;
    }

    protected override void OnInitialized()
    {
        base.OnInitialized();
        searchData();
    }

    //自定义排序
    object sortFun(object value)
    {
        var p = (Person) value;
        return p.Name.Length; //毫无意义的排序
    }

}